#include "iconloader.h"
#include <QDebug>
#include <QDir>
#include <QFile>
#include <QCoreApplication>


QList<int> IconLoader::sizes_;
QString IconLoader::custom_icon_path_;
QList<QString> IconLoader::icon_sub_path_;
bool IconLoader::use_sys_icons_;

 void IconLoader::Init()
 {

     sizes_.clear();
     sizes_ << 22 << 32 << 48;
     custom_icon_path_ =  QCoreApplication::applicationDirPath() + "/icons";


 }

 QIcon IconLoader::Load(const QString &name,const IconType & icontype)
 {
     QIcon ret;

     switch (icontype) {
     case Base:
     case Provider:{

         const QString filename_custom = custom_icon_path_ +"/" + name +".png";
         qInfo()<<filename_custom;
         if(QFile::exists(filename_custom)){
             ret.addFile(filename_custom,QSize(48,48));
         }
         if(!ret.isNull()){
             return ret;
         }

         break;
     }
     case LastFM:
     case Other:
     {
         break;
     }
     default:
         qWarning()<<"Couldn't load icon"<<name;

     }

     if (ret.isNull()) {
         ret = QIcon::fromTheme(name);
         if (!ret.isNull()) return ret;
         qWarning() << "Couldn't load icon" << name;
     }
     return ret;
 }
